import java.util.Scanner;

/**
 * @author gao
 * @date 2025/9/8 8:08
 */

public class Solution {
    public int findMaxConsecutiveOnes(int[] nums) {
        // 记录最大连续1的个数和当前连续1的个数
        int maxCount = 0, curCount = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 1) {
                curCount++;
                // 遇到1，当前连续1的个数+1
                maxCount = Math.max(maxCount, curCount);
            } else {
                curCount = 0;
            }
        }
        return maxCount;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < nums.length; i++) {
                nums[i] = in.nextInt();
            }
            Solution solution = new Solution();
            System.out.println(solution.findMaxConsecutiveOnes(nums));
        }
    }
}